package com.finance.rule.service;


import com.finance.framework.lang.Page;
import com.finance.framework.lang.PageResultBO;
import com.finance.rule.bean.pojo.MajorRule;
import com.finance.rule.dao.MajorRuleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
public class MajorRuleService implements IMajorRuleService {
	@Autowired
	private MajorRuleMapper majorRuleMapper;


	@Override
	public MajorRule getById(long id) {
		return majorRuleMapper.getById(id);
	}

	@Override
	public MajorRule getBySupplier_code(String code) {
		return majorRuleMapper.getBySupplierCode(code);
	}

	@Override
	public List<MajorRule> listAll(){
		return majorRuleMapper.listAll();
	}

	@Override
	public PageResultBO<MajorRule> listByPage(Page page) {
		PageResultBO<MajorRule> pageResultBO = new PageResultBO<MajorRule>();
		List<MajorRule> list = majorRuleMapper.listByPage(page);
		pageResultBO.setPageSize(page.getPageSize());
		pageResultBO.setTotalRecord(page.getTotalRecord());
		pageResultBO.setPageNo(page.getPageNo());
		pageResultBO.setDataList(list);
		return pageResultBO;
	}

	@Override
	public boolean add(MajorRule majorRule) {
		return majorRuleMapper.add(majorRule) == 1;
	}

	@Override
	public boolean update(MajorRule majorRule) {
		return majorRuleMapper.update(majorRule) == 1;
	}

	@Override
	public Map<String, String> getDescription(String parser) {
		return majorRuleMapper.getDescription(parser);
	}

	@Override
	public boolean supplierCodeExist(String supplierCode) {
		return majorRuleMapper.supplierCodeExist(supplierCode)==0;
	}
}
